<?php
// +----------------------------------------------------------------------
// | YZCMS <XueHen CMS>
// +----------------------------------------------------------------------
// | Copyright (c) http://www.xuehen.org
// +----------------------------------------------------------------------
// | Author XueHen <490860758@qq.com>
// +----------------------------------------------------------------------
namespace Admin\Controller;

class BookController extends BaseController {
    function index(){
		$shownum = F('HouShowNum');
		$page = isset($_GET['p']) ? $_GET['p'] : 1;
		
		$db = M('book');
		$count         = $db->count();
		$Page          = new \Think\Page($count,$shownum);
		$this->page    = $Page->show();
		$this->article = $db->order('id desc')->page($page.','.$shownum)->select();
        $this->display();
    }
	
	function set(){
		$this->show = F('comment_show');
		$this->must = F('comment_must');
		$this->display();
	}
	
	function edit(){
		$show = array('state'=>I('comment','open'),'name'=>I('name_show','0'),'email'=>I('email_show','0'),'web'=>I('web_show','0'),'verify'=>I('verify_show','0'));
		$must = array('name'=>I('name_must','0'),'email'=>I('email_must','0'),'web'=>I('web_must','0'),'verify'=>I('verify_show','0'));
		F('comment_show',$show);
		F('comment_must',$must);
		$this->success('修改成功！',U('set'));
	}
	
	function del(){
	    $id = I('id');
		if(!$id){
			$this->error('无效的参数');
			exit;
		}
		$db = M('book');
		$rid = $db->where('id = '.I('id'))->delete();
		if($rid){
			$this->success('删除成功！',U('index'));
		}else{
			$this->error('删除失败!');
		}
		
	}
	
	
}